package com.yygo.webapp.controller;

import com.yygo.util.IdCardValidator;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import java.util.Date;
import java.util.Locale;

/**
 * Created by tiansha on 2015/7/6.
 */
@Controller
@RequestMapping("/idcardValidate")
public class IDCardController extends BaseFormController {

    @RequestMapping(method = RequestMethod.GET, produces="text/plain;charset=utf-8")
    @ResponseBody
    public String handleRequest(@RequestParam(required = false, value = "idcard") String idcard, @RequestParam(required = false, value = "birthday") Date birthday) throws Exception {
        return getText("ID_error_" + IdCardValidator.valideIdCard(idcard, birthday), Locale.SIMPLIFIED_CHINESE);
    }
}
